Python: Simple graph representation. Test fails

welcome to shbcf.ru